//
//  QLTimeVIew.m
//  QLCustomCamera_Example
//
//  Created by 李强 on 2020/8/29.
//  Copyright © 2020 李强LiQ. All rights reserved.
//

#import "QLTimeVIew.h"
#import <Masonry/Masonry.h>
#import "UIImage+QLImage.h"


#define TIME_MARGIN 10

@implementation QLTimeVIew

-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
//        self.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.3];
        [self createTimePage];
    }
    return self;
}

-(void)createTimePage
{
    UIImageView *timeView = [[UIImageView alloc]initWithImage:[UIImage getBundleImageWithName:@"time_sign" className:NSStringFromClass([self class])]];
    [self addSubview:timeView];
    [timeView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(TIME_MARGIN);
        make.centerY.equalTo(self);
    }];
    
    UILabel *lab = [[UILabel alloc]init];
    _timeLB = lab;
    lab.text = @"00秒";
    lab.textAlignment = NSTextAlignmentRight;
    lab.textColor = [UIColor whiteColor];
    lab.font = [UIFont systemFontOfSize:14.f];
    [self addSubview:lab];
    [lab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-TIME_MARGIN);
        make.centerY.equalTo(self);
    }];
}

//-(void)reloadTime:(NSInteger)time
//{
//    self.timeLB.text = [self returnTimeString:time];
//}
//
//
//-(NSString *)returnTimeString:(NSInteger)time
//{
//    NSInteger hour = time / 3600;
//    NSInteger min = (time%3600)/60;
//    NSInteger sec = (time%3600)%60;
//    NSString *hourStr = [NSString stringWithFormat:@"%@",hour > 0 ? [NSString stringWithFormat:@"%02ld:",hour] : @""];
//    NSString *timeStr = [NSString stringWithFormat:@"%@%02ld:%02ld",hourStr,(long)min,(long)sec];
//    return timeStr;
//}




























@end
